package club.framework.web.base.common;

/**
 * Created by 念梓  on 2017/9/6.
 * Email:sunmch@163.com
 * author: 念梓
 * des:加密算法枚举
 */
public enum Algorithm {


    DES("DES", "DES encrypt"), AES("AES", "AES encrypt"), BLOWFISH("BLOWFISH", "Blowfish encrypt"), RC2("RC2",
            "RC2 encrypt"), RC4("RC4", "RC4 encrypt");

    /** 主键 */
    private final String key;

    /** 描述 */
    private final String desc;

    Algorithm(final String key, final String desc) {
        this.key = key;
        this.desc = desc;
    }

    public String getKey() {
        return this.key;
    }

    public String getDesc() {
        return this.desc;
    }

    public static Algorithm convert(String encryptAlgorithm) {
        Algorithm algorithm = Algorithm.RC4;
        if (null != encryptAlgorithm) {
            Algorithm[] algs = Algorithm.values();
            for (Algorithm alg : algs) {
                if (alg.getKey().equals(encryptAlgorithm)) {
                    algorithm = alg;
                    break;
                }
            }
        }
        return algorithm;
    }

}
